﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;

namespace XmlDSigEx
{
    class ExcC14NTransform:ITransform
    {
        private ICanonicalisationAlgorithm _canonicalisation = new ExcXmlC14NCanonicalisation();

        #region ITransform Members

        public bool SupportsInputType(Type inputType)
        {
            return true;
        }

        public object Process(object input, XmlElement transformElement)
        {
            Stream octetStream = input as Stream;
            if (octetStream != null)
            {
                return _canonicalisation.ProcessOctetStream(octetStream,false);
            }
            List<XmlNode> nodeSet = input as List<XmlNode>;
            if (nodeSet != null)
            {
                return _canonicalisation.ProcessNodeSet(nodeSet, false);
            }
            throw new ArgumentException("A data type that was not either a List<XmlNode> or Stream object was encountered while processing the transform chain.");
        }

        public void WriteXml(XmlWriter writer)
        {
        }

        public string Uri
        {
            get
            {
                return ExcXmlC14NCanonicalisation.URI_EXC_C14N;
            }
        }

        #endregion
    }
}
